<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2022-2099 李志刚（854378082@qq.com）
 * @Date: 2020-02-29 08:53:37
 * @Description: 友情链接模型
 * @LastEditors: 李志刚
 * @LastEditTime: 2022-04-30 09:27:58
 * @FilePath: /CoinCMF/app/Models/Content/Link.php
 */

namespace App\Models\Content;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Link extends Model
{
    use HasFactory;
    /**
     * 关联到模型的数据表
     *
     * @var string
     */
    protected $table = 'cms_link';
    /**
     * 不可以批量赋值的字段，为空则表示都可以
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $hidden = [];

    /**
     * 表明模型是否应该被打上时间戳
     *
     * @var bool
     */
    public $timestamps = true;
    // 自动生成的时间要加时区约束
    public function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [];
    // 关联
    public function linktype()
    {
        return $this->belongsTo('\App\Models\Content\LinkType', 'linktype_id', 'id');
    }
}